import fetch from 'common/src/utils/fetch';
/**
 *
 * 查询课程组(分页)
 */
export function findCourseGroups(data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/findCourseGroups',
        method: 'post',
        data
    });
}

/**
 *
 * 根据主键查询课程组详细信息
 */
export function findCourseGroupById(id) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/findCourseGroupById?id=' + id,
        method: 'get'
    });
}

/**
 *
 *添加课程组
 */
export function insertCourseGroup(data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/insertCourseGroup',
        method: 'post',
        data
    });
}
/**
 *
 *修改课程组
 */
export function updateCourseGroup(data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/updateCourseGroupById',
        method: 'post',
        data
    });
}
/**
 *
 *删除课程组
 */
export function delCourseGroupById(id) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/delCourseGroupById?id=' + id,
        method: 'delete'
    });
}

/**
 *
 * 查询课程组下对应的所有课程
 */
export function getCoursesByGroupId(id) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/getCoursesByGroupId?id=' + id,
        method: 'get'
    });
}

/**
 *
 *查询课程组下对应的所有教室
 */
export function getClassRoomsByGroupId(id, pageNum, pageSize) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/getClassRoomsByGroupId?id=' +
      id +
      '&pageNum=' +
      pageNum +
      '&pageSize=' +
      pageSize,
        method: 'get'
    });
}

/**
 *
 *在课程组里添加课程
 */
export function insertCourses(groupId, data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/insertCourses?groupId=' +
      groupId,
        method: 'post',
        data
    });
}

/**
 *
 *在课程组里添加教室
 */
export function insertRooms(groupId, data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/insertRooms?groupId=' +
      groupId,
        method: 'post',
        data
    });
}

/**
 *
 *批量删除课程组里的课程教室
 */
export function delRooms(groupId, data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/delRooms?groupId=' + groupId,
        method: 'delete',
        data
    });
}

/**
 *
 *批量删除课程组里的课程课程
 */
export function delCourses(groupId, data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/delCourses?groupId=' + groupId,
        method: 'delete',
        data
    });
}

/**
 * 获取自动排课页面数据
 */
export function getTeacherCode(data) {
    return fetch({
        url: '/api/arrangementservice/autoArrange/getTeacherCode',
        method: 'POST',
        data
    });
}

/**
 * 分配教室
 */
export function autoArrangeRoom(data) {
    return fetch({
        url: '/api/arrangementservice/autoArrange/autoArrangeRoom',
        method: 'POST',
        data
    });
}

/**
 * 取消分配
 */
export function cancleArr(data) {
    return fetch({
        url: '/api/arrangementservice/autoArrange/cancleArr',
        method: 'POST',
        data
    });
}

/**
 * 导出
 * @param {*} params
 */
export function getResultByKey(key) {
    return fetch({
        url: '/api/arrangementservice/autoArrange/result/' + key,
        method: 'get'
    });
}

/**
 *
 *修改课程组中教室的排序
 */
export function updateRoomOrder(groupId, data) {
    return fetch({
        url: '/api/arrangementservice/courseGroup/updateRoomOrder?groupId=' +
      groupId,
        method: 'post',
        data
    });
}

/**
 *
 *保存自动排教室中的结果
 */
export function saveSelect(data) {
    return fetch({
        url: '/api/arrangementservice/autoArrange/saveSelect',
        method: 'post',
        data
    });
}
